package com.jinpeng.redis.controller;


import com.jinpeng.redis.entity.User;
import com.jinpeng.redis.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jp
 * @since 2020-01-07
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private  IUserService iUserService;

    @RequestMapping(value = "selectUser",method = RequestMethod.POST)
    public User selectUser(String id){
        return iUserService.selectUser(id);
    }


    @RequestMapping(value = "selectUserList",method = RequestMethod.POST)
    public List<User> selectUserList(){
        return iUserService.selectUserList();
    }

    @RequestMapping(value = "selectUserCacheList",method = RequestMethod.POST)
    public List<User> selectUserCacheList(){
        return iUserService.selectUserCacheList();
    }


    @RequestMapping(value = "insertUser",method = RequestMethod.POST)
    public User insertUser(){
        User user = new User();
        user.setUserName("小菜鸟");
        user.setAge(24);
        user.setHigh(174);
        user.setSex("男");
        user.setCreateTime(LocalDateTime.now());
        user.setEndTime(LocalDateTime.now());
        return iUserService.insertUser(user);
    }
}
